package org.ats.mail;

import java.io.File;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("MailThreadPool")
public class MailThreadPool{
	
	private ExecutorService es = Executors.newFixedThreadPool(10);
	@Autowired
	private AtsMailSender ams;
	
	public AtsMailSender getAms() {
		return ams;
	}

	public void setAms(AtsMailSender ams) {
		this.ams = ams;
	}

	public void mailSender(MailTemplates mailTemp, List<String> mailToList, File attachment){
		
		System.out.println(getAms() == null);
		synchronized(ams){
			ams.setMailTemp(mailTemp);
			ams.setMailToList(mailToList);
			ams.setAttachment(attachment);
			es.submit(ams);
		}		
	}

}
